package com.py.credit.service.impl;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.py.credit.dao.MulQueryDao;
import com.py.credit.service.MulQueryService;
import com.py.credit.utils.SQLBuilder;
import com.py.framework.core.common.Page;

@Service
public class MulQueryServiceImpl implements MulQueryService {

	@Autowired
	private MulQueryDao mulQueryDao;

	@Override
	public List<LinkedHashMap<String, Object>> getByConditionForPage(List<String> columns, String[] additionalColumns,
			String conditionStr, Page page, String orgId, String sqr_str, String reportType, String shzt) {
		List<String> conditions = SQLBuilder.createConditionSql(conditionStr);
		return mulQueryDao.selectByConditionForPage(columns, additionalColumns,
				conditions, page, orgId, sqr_str, reportType, shzt);
	}

	@Override
	public List<Map<String, Object>> selectAllReportGet(String reportType, String mainType, String recieveStatus,
			String orgId, List<String> columns, String[] additionalColumns, String condition, Page page) {
		List<Map<String, Object>> reportGetList = new ArrayList<Map<String, Object>>();
		List<String> conditions = SQLBuilder.createConditionSql(condition);
		reportGetList = mulQueryDao.selectAllReportGetByConditionForPage(reportType, mainType, recieveStatus, orgId,
				columns, additionalColumns, conditions, page);
		return reportGetList;
	}

	@Override
	public List<Map<String, Object>> selectReportHistoryForPage(String bgbh, String lqr, String orgId, Page page) {
		List<Map<String, Object>> reportGetList = new ArrayList<Map<String, Object>>();
		reportGetList = mulQueryDao.selectReportHistoryForPage(bgbh, lqr, orgId, page);
		return reportGetList;
	}

	@Override
	public void updateReportshzt(String bgbh, String id, String lqr, String lqtype, String lqbz, String file,
			String orgId) {
		mulQueryDao.updateReportshzt(bgbh);
		mulQueryDao.insertReportHistory(bgbh, lqr, file, lqtype, lqbz, orgId, id);

	}

}
